<?php
/*! \brief
 * This is abstract class of Fixtures
 * This is Fixtures class for unit test,
 * initial predefine data to /path/to/db/sqlite/tmwf_test.db before testing specific method,
 * destory predefine data from /path/to/db/sqlite/tmwf_test.db after testing specific method.
 * \author William Su
 */
abstract class AFixtures
{
	/**
	 * @var WFWidgetPoolFactory
	 */
	protected $objWidgetPoolFactory;
	/**
	 * @var WF
	 */
	protected $objFramework;
	protected static $instance;
	public function __construct($objFramework){
		$this->objFramework = $objFramework;
		$this->objWidgetPoolFactory = $this->objFramework->getWidgetPoolFactory();
	}
	protected function setUp($strTableName,$assocsData){
		//var_dump($assocsData);exit();
		if(!(is_array($assocsData) && $assocsData)){
			return false;
		}
		/* Propel Statement
		$strFuncName = $this->objFramework->getTypeFactory()->getString()->getUpperCamelCase($strTableName);
		$objQuery = new $strFuncName();
		*/
		//var_dump($objQuery);exit();
		foreach($assocsData as $assocData){
			$objParameter = $this->objWidgetPoolFactory->getParameter();
			$objParameter->setAssocData($assocData);
			$objParameter->appendFrom($strTableName);
			
			$result = $this->objWidgetPoolFactory->getDataObject()->queryInsertByParameter($objParameter);
		}
	}
	protected function tearDown($strTableName){
		$this->objWidgetPoolFactory->getWidgetPoolDB()->truncateWidgetPoolTable($strTableName);
	}
	public function appendAssocsData(&$assocData){
		self::$instance['AssocsData'][] = $assocData;
		$assocData = null;
	}
	public function getAssocsData(){
		$ret = self::$instance['AssocsData'];
		self::$instance['AssocsData'] = null;
		return $ret;
	}
}